// // Copyright (c) 2009 All Right Reserved // // vl // // 2009-01-01 // Contains ... // Class to represent one MIDI block. using LargoCommon.Abstract; using LargoCommon.Music; namespace LargoCommon.Midi { /// /// Midi Block. /// public sealed class MidiBlock : IMidiBlock { /// /// Initializes a new instance of the class. /// /// The bar number. /// The given header. /// The tonality key. /// The tempo. public MidiBlock(int barNumber, MusicalHeader givenHeader, TonalityKey tonalityKey, int tempo) { this.Area = new MusicalSection(barNumber, DefaultValue.MaximumBarNumber, null); this.Header = givenHeader; this.TonalityKey = tonalityKey; this.Tempo = tempo; this.TonalityGenus = TonalityGenus.Major; //// this.CheckTempo(); this.GuessName(); } #region Properties /// /// Gets or sets the header. /// /// /// The header. /// public MusicalHeader Header { get; set; } /// /// Gets or sets the sequence. /// /// /// The sequence. /// public CompactMidiStrip Sequence { get; set; } /// /// Gets Musical Area. /// /// Property description. public MusicalSection Area { get; } /// /// Gets or sets the midi time from. /// /// /// Property description. /// public long MidiTimeFrom { get; set; } /// /// Gets or sets the midi time to. /// /// /// Property description. /// public long MidiTimeTo { get; set; } /// Gets the rhythmical order. /// Property description. public int Tempo { get; private set; } /// /// Gets the tonality key. /// /// /// The tonality key. /// public TonalityKey TonalityKey { get; } /// /// Gets the tonality genus. /// /// /// The tonality genus. /// public TonalityGenus TonalityGenus { get; } #endregion /// /// Checks the tempo. /// public void CheckTempo() { if (this.Tempo != 0) { return; } this.Tempo = DefaultValue.DefaultTempo; //// MessageBox.Show("Default tempo assigned!"); } /// /// Guesses the name. /// private void GuessName() { this.Header.Name = MusicalProperties.GetTempoValue(this.Tempo); if (this.TonalityKey == TonalityKey.None) { return; } var t = this.TonalityKey.ToString().Replace('s', '#'); t = t.Replace("Tonality", string.Empty); this.Header.Name += " in " + t; } } }